package com.item.daoEx.model;

import java.util.ArrayList;
import java.util.List;

public class Year {
	private String id;
	private String name;
	private String code;
	private static List<Year> list = new ArrayList<Year>();
	
	static {
		list.add(new Year("1", "大一", "Y01"));
		list.add(new Year("2", "大二", "Y03"));
		list.add(new Year("3", "大三", "Y03"));
		list.add(new Year("4", "大四", "Y04"));
		list.add(new Year("5", "大五", "Y05"));
	}
	
	public Year() {
		super();
	}
	
	public Year(String id, String name, String code) {
		super();
		this.id = id;
		this.name = name;
		this.code = code;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	
	public static List<Year> listYear() {
		return list;
	}
	
	public static Year getYearByCode(String code) {
		Year res = new Year("", "请选择..." , "");
		
		for(Year y : list) {
			if(y.getCode().equals(code)) {
				res = y;
				
				break;
			}
		}
		
		return res;
	}
}
